package com.cbank.service;

import com.cbank.dao.AboutUsBannerDao;
import com.cbank.domain.AboutUsBanner;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AboutUsBannerService {

    private Logger logger=Logger.getLogger(AboutUsBannerService.class);

    @Autowired
    private AboutUsBannerDao aboutUsBannerDao;

    public AboutUsBanner getById(Integer id){
        return this.aboutUsBannerDao.getById(id);
    }

    public AboutUsBanner getByViewId(String viewId){
        return this.aboutUsBannerDao.getByViewId(viewId);
    }

    public List<AboutUsBanner> getByAboutUsId(Integer aboutusId){
        return this.aboutUsBannerDao.getListByAboutUsId(aboutusId);
    }

    public void save(AboutUsBanner aboutUsBanner){
        AboutUsBanner usBanner=this.aboutUsBannerDao.getById(aboutUsBanner.getId());
        if (usBanner == null){
            this.aboutUsBannerDao.insert(aboutUsBanner);
        }else {
            this.aboutUsBannerDao.update(aboutUsBanner);
        }
    }
}
